const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: './index.js',
  output: {
    filename: 'main.js',
    path: path.resolve(__dirname, 'dist'),
  },
  module: {
    rules: [
      {
        test: /\.m?js$/,
        exclude: /(node_modules|bower_components)/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env'],
          },
        },
      },
    ]
  },
  plugins: [new HtmlWebpackPlugin()],
  devtool: 'source-map', // 包含所有中间过程loader映射
  // devtool: 'cheap-module-source-map', // 仅行映射，切不包含中间loader处理过程映射，直接映射回源码
  // devtool: 'eval-source-map',
  // devtool: 'eval',
  mode: 'production',
};